package me.jessyan.mvparms.demo.di.module.fragment;

import com.jess.arms.di.scope.FragmentScope;
import com.tbruyelle.rxpermissions2.RxPermissions;

import dagger.Module;
import dagger.Provides;

import me.jessyan.mvparms.demo.mvp.contract.fragment.LifeContract;
import me.jessyan.mvparms.demo.mvp.model.fragment.LifeModel;


@Module
public class LifeModule {
    private LifeContract.View view;

    /**
     * 构建LifeModule时,将View的实现类传进来,这样就可以提供View的实现类给presenter
     *
     * @param view
     */
    public LifeModule(LifeContract.View view) {
        this.view = view;
    }

    @FragmentScope
    @Provides
    LifeContract.View provideLifeView() {
        return this.view;
    }

    @FragmentScope
    @Provides
    LifeContract.Model provideLifeModel(LifeModel model) {
        return model;
    }


    @FragmentScope
    @Provides
    RxPermissions providePersonalRxPermissions(){
        return new RxPermissions(view.getFragment());
    }
}